<template>
    <div class="left">
      <div class="logo-container">
      <h2 class="logo-text">
        <i class="logo-icon"></i>
        小米后台管理
      </h2>
    </div>
      <nav class="sidebar-nav">
      <ul class="nav-menu">
        <li class="nav-item" v-for="item in menuItems" :key="item.path">
          <router-link 
            :to="item.path" 
            class="nav-link"
            active-class="active-link"
          >
            <i :class="['nav-icon', item.icon]"></i>
            <span class="nav-text">{{ item.name }}</span>
          </router-link>
        </li>
      </ul>
    </nav>
    </div>
</template>

<script setup>
import { ref } from 'vue';
const menuItems = ref([
  { name: '首页', path: '/adminShortCut', icon: 'icon-home' },
  { name: '商品管理', path: '/admingoods', icon: 'icon-goods' },
  { name: '用户管理', path: '/adminusers', icon: 'icon-users' },
  { name: '订单管理', path: '/adminorder', icon: 'icon-orders' },
  { name: '评论管理', path: '/adminreviews', icon: 'icon-reviews' },
  { name: '轮播图管理', path: '/adminlunbo', icon: 'icon-slider' }
]);
</script>

<style lang="scss" scoped>

.left {
  width: 250px;
  background: linear-gradient(to bottom, #444, #333);
  color: white;
  height: 100vh;
  padding: 20px;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.sidebar-container {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: all 0.3s ease;
  overflow-y: auto;
  
  &:hover {
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
  }
}

.logo-container {
  padding: 25px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  
  .logo-text {
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    
    .logo-icon {
      display: inline-block;
      width: 30px;
      height: 30px;
      background-image: url('https://s01.mifile.cn/favicon.ico');
      background-size: contain;
      background-repeat: no-repeat;
      margin-right: 10px;
    }
  }
}
.logo {
  text-align: center;
  margin-bottom: 20px;
  h2 {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
  }
}

.sidebar-nav {
  padding: 20px 0;
}

.nav-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  margin: 8px 15px;
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.3s ease;
  
  &:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
  }
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 20px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 16px;
  transition: all 0.3s ease;
  
  &:hover {
    color: #fff;
  }
  
  &.active-link {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
    border-left: 3px solid #ff9800;
    
    .nav-icon {
      color: #ff9800;
    }
  }
}

.nav-icon {
  font-size: 18px;
  margin-right: 12px;
  width: 50px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  
  /* 使用字体图标或自定义图标 */
  &.icon-home::before { content: "🏠"; }
  &.icon-goods::before { content: "📦"; }
  &.icon-users::before { content: "👥"; }
  &.icon-orders::before { content: "📝"; }
  &.icon-reviews::before { content: "💬"; }
  &.icon-slider::before { content: "🖼️"; }
}

.nav-text {
  flex: 1;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar-container {
    width: 70px;
    
    .logo-text span,
    .nav-text {
      display: none;
    }
    
    .nav-link {
      justify-content: center;
      padding: 15px 0;
    }
    
    .nav-icon {
      margin-right: 0;
      font-size: 20px;
    }
  }
}

</style>


